"""
需求：使用requests访问登录接口，并查看响应结果。
接口信息：
地址：http://kdtx-test.itheima.net/api/login
方法：Post
请求数据：
请求头：Content-Type: application/json
请求体：{"username":”admin", "password": " admin123","code":"2", "uuid":"验证码接口返回数据"}

"""
# 导包
import requests

# 发送请求
url = "http://kdtx-test.itheima.net/api/login"
# headers_data = {
#     "Content-Type": "application/json"
# }
test_data = {
    "username": "admin",
    "password": "admin123",
    "code": "2",
    "uuid": "8db6330c448b47118bb335ad5c0b6901"
}
# response = requests.post(url=url, headers=headers_data, json=test_data)
response = requests.post(url=url, json=test_data)

# 查看响应
# 获取响应状态码
print(response.status_code)
# 获取文本数据
print(response.text)
# 获取json返回数据
print(response.json())
print(response.json().get("msg"))
print(response.json().get("code"))
